<template>
	<view class="container">
		<view class="clock-header">
			<image class="clock-header__avatar" :src="teacher.avatar" mode="aspectFill"></image>
			<view class="clock-header__content">
				<view class="name">{{teacher.name}}</view>
				<view class="time">{{teacher.date_text}}</view>
			</view>
			<u-icon @click="daka_log" name="arrow-right" color="#D7D7D7" size="22" label="全部考勤" label-color="#6D4BBE" label-size="24" label-pos="left" margin-right="8"></u-icon>
		</view>
		<view class="clock-warpper">
			<view class="clock-warpper__rows">
				<view class="clock-warpper__cell">
					<view class="title">上班打卡</view>
					<view class="subtit">{{teacher.shop.start_work_time}}</view>
					<view class="state " :class="teacher.start_work_status=='1'?'':'col-1'">{{teacher.start_work_status=='1'?'已打卡':'未打卡'}}</view>
				</view>
				<view class="clock-warpper__cell">
					<view class="title">下班打卡</view>
					<view class="subtit">{{teacher.shop.end_work_time}}</view>
					<view class="state " :class="teacher.end_work_status=='1'?'':'col-1'">{{teacher.end_work_status=='1'?'已打卡':'未打卡'}}</view>
				</view>
			</view>
			<view class="clock-warpper__tool">
				<view @click="daka" class="clock-warpper__btn " :class="(teacher.show_tips==1 && teacher.start_work_status==0) || (teacher.show_tips==2 && teacher.end_work_status==0)?'':'unable'">
					<view class="title">{{teacher.show_tips==1?'上班打卡':'下班打卡'}}</view>
					<view class="time">{{teacher.show_tips==1?teacher.shop.start_work_time:teacher.shop.end_work_time}}</view>
				</view>
				<view class="clock-warpper__site">
					<view>{{teacher.shop.name}}</view>
					<view>{{teacher.shop.Area.province+teacher.shop.Area.city+teacher.shop.Area.region+teacher.shop.detail}}</view>
				</view>
			</view>
		</view>
		<view class="clock-remind">
			<u-icon name="info-circle-fill" color="#F5C822" size="32" label="12点上班时间未打卡将无法打卡,请及时打卡" label-color="#999999" label-size="24" label-pos="right" margin-right="8"></u-icon>
		</view>
		<!-- 底部导航栏 start -->
		<wd-tabbar class="wd-tabbar" iconSize="44" :list="wd_tabbar_teacher" :isTabBar="false"></wd-tabbar>
		<!-- 底部导航栏 end -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				teacher:{}
			}
		},
		onShow(){
			this.fetchUserinfo();
		},
		methods: {
			
			daka(){
				var that = this;
				var type = that.teacher.show_tips;
				if(!type){
					http.toast('打卡参数错误');
					return false;
				}
				if((type == 1 && that.teacher.start_work_status==1) || (type == 2 && that.teacher.end_work_status==1)){
					http.toast('不要重复打卡');
					return false;
				}
				var option = {
					tip_status: true,
					method: 'POST',
					tips: 'loading',
					url: 'api/teacher/daka',
					data: {type:type,position:''}
				};
							
				http.common_request(that,option,function(data){
					if(data.code == '1'){
						http.toast('打卡成功')
						that.get_teacher();
					}
				})
			},
			
			//获取信息
			fetchUserinfo(){
				var that = this;
				that.$core.get({url:'fitness.user/index',data:{},success:(ret)=>{
					if(!ret.data.teacher_status){
						uni.showModal({
							title: '提示',
							content: '您不是老师，不可查看',
							success:function(res) {
								uni.navigateBack({
									
								})
							}
						});
						return false;
					}
					that.teacher = ret.data.teacher;
				}});
			},
			daka_log(){
				uni.navigateTo({
					url: '/pages/teacher/clockRecord/clockRecord'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 1rpx 0;
		background: #F6F6F6;
	}
	.clock-header {
		display: flex;
		align-items: center;
		margin: 24rpx;
		padding: 24rpx;
		background: #FFFFFF;
		border-radius: 24rpx;
		overflow: hidden;
		&__avatar {
			display: block;
			margin-right: 40rpx;
			width: 120rpx;
			height: 120rpx;
			border-radius: 50%;
		}
		&__content {
			flex: 1;
			overflow: hidden;
			.title {
				line-height: 48rpx;
				font-size: 34rpx;
				font-weight: 500;
				color: #333333;
			}
			.time {
				margin-top: 10rpx;
				line-height: 40rpx;
				font-size: 28rpx;
				color: #666666;
			}
		}
	}
	.clock-warpper {
		margin: 24rpx;
		padding: 34rpx;
		background: #FFFFFF;
		border-radius: 24rpx;
		overflow: hidden;
		&__rows {
			display: flex;
			justify-content: space-between;
			align-items: center;
		}
		&__cell {
			width: 310rpx;
			min-height: 170rpx;
			padding: 24rpx 34rpx;
			background: #F8F8F8;
			border-radius: 24rpx;
			.title {
				line-height: 40rpx;
				font-size: 28rpx;
				font-weight: 500;
				color: #333333;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
			.subtit {
				line-height: 40rpx;
				font-size: 26rpx;
				color: #333333;
			}
			.state {
				line-height: 40rpx;
				font-size: 22rpx;
				color: #999999;
				&.col-1 {
					color: #6D4BBE;
				}
				&.col-2 {
					color: #EE0000;
				}
			}
		}
		&__tool {
			padding: 100rpx 0;
		}
		&__btn {
			display: block;
			margin: 0 auto;
			padding: 64rpx 10rpx;
			width: 230rpx;
			height: 230rpx;
			background: linear-gradient(131deg, #A36BFF 0%, #6D4BBE 100%);
			text-align: center;
			color: #FFFFFF;
			border-radius: 50%;
			&.unable {
				background: #D8D8D8;
			}
			.title {
				line-height: 36rpx;
				font-size: 26rpx;
			}
			.time {
				line-height: 66rpx;
				font-size: 46rpx;
			}
		}
		&__site {
			margin-top: 38rpx;
			text-align: center;
			line-height: 38rpx;
			font-size: 26rpx;
			color: #333333;
		}
	}
	.clock-remind {
		margin: 24rpx;
		padding: 10rpx 50rpx;
	}
</style>